﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media.Media3D;
using System.Xml;
using System.Globalization;
using System.Collections.ObjectModel;
using System.Diagnostics;

namespace SkeletalAnimation3D.Core
{
    public class BoneOrientationDictionary : KeyedCollection<int, BoneOrientation>
    {
        public BoneOrientationDictionary()
        {
        }

        public static void InterpolateBoneTransformations(BoneOrientationDictionary previous, BoneOrientationDictionary next, double deltaProgress, SkeletonInfo result)
        {
            foreach (BoneOrientation boneOrientation in previous)
            {
                Quaternion interpolation = Quaternion.Slerp(boneOrientation.Orientation, next[boneOrientation.BoneId].Orientation, deltaProgress, false);
                result.SetOrientation(boneOrientation.BoneId, interpolation);
            }
        }

        protected override int GetKeyForItem(BoneOrientation item)
        {
            return item.BoneId;
        }
    }
}
